package com.ym.b2b.product.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.product.dao.EmBProductPaperBatchDAO;
import com.ym.b2b.product.sqlbean.EmBProductPaperBatch;
import com.zc.commons.base.Page;

@Repository
public class EmBProductPaperBatchDAOImpl<T> extends BaseDao<T> implements EmBProductPaperBatchDAO {

    public Long searchPageEmBProductPaperBatchNum(EmBProductPaperBatch embproductpaperbatch) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embproductpaperbatch);
        return (Long) listNum("EM_B_PRODUCT_PAPER_BATCH.searchPageEmBProductPaperBatchNum", map);
    }

    public void searchPageEmBProductPaperBatch(EmBProductPaperBatch embproductpaperbatch,
                                               Page<EmBProductPaperBatch> page) throws DataAccessException {
        page.setTotalRow(searchPageEmBProductPaperBatchNum(embproductpaperbatch));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embproductpaperbatch);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_B_PRODUCT_PAPER_BATCH.searchPageEmBProductPaperBatch", map));
    }

    public void insertEmBProductPaperBatch(EmBProductPaperBatch record) throws DataAccessException {
        insert("EM_B_PRODUCT_PAPER_BATCH.insertEmBProductPaperBatch", record);
    }

    public int updateEmBProductPaperBatch(EmBProductPaperBatch record) throws DataAccessException {
        int rows = update("EM_B_PRODUCT_PAPER_BATCH.updateEmBProductPaperBatch", record);
        return rows;
    }

    public EmBProductPaperBatch showEmBProductPaperBatch(EmBProductPaperBatch paperBatchId) throws DataAccessException {

        return (EmBProductPaperBatch) find("EM_B_PRODUCT_PAPER_BATCH.searchEmBProductPaperBatch", paperBatchId);
    }

    public int deleteEmBProductPaperBatch(EmBProductPaperBatch paperBatchId) throws DataAccessException {

        int rows = delete("EM_B_PRODUCT_PAPER_BATCH.deleteEmBProductPaperBatch", paperBatchId);
        return rows;
    }

    @Override
    public List<EmBProductPaperBatch> searchEmBProductPaperBatch(EmBProductPaperBatch paperBatchId)
                                                                                                   throws DataAccessException {
        return list("EM_B_PRODUCT_PAPER_BATCH.searchEmBProductPaperBatch", paperBatchId);
    }
}
